// 引入SDK核心类，js文件根据自己业务，位置可自行放置
var QQMapWX = require('./libs/qqmap-wx-jssdk');
var qqmapsdk;
Page({

    data:{
        selectedid: 0,
        markers: [
            {
                iconPath: "/images/非遗文化-01.png",
                id: 0,
                latitude: 39.9042, // 北京市
                longitude: 116.4074,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 1,
                latitude: 31.2304, // 上海市
                longitude: 121.4737,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 2,
                latitude: 23.1291, // 广州市
                longitude: 113.2644,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 3,
                latitude: 29.5616, // 南京市
                longitude: 106.5516,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 4,
                latitude: 36.0654, // 济南市
                longitude: 120.3808,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 5,
                latitude: 43.8176, // 哈尔滨市
                longitude: 126.5350,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 6,
                latitude: 40.0583, // 天津市
                longitude: 116.3972,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 7,
                latitude: 34.3416, // 西安市
                longitude: 108.9398,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 8,
                latitude: 29.5616, // 重庆市
                longitude: 106.5516,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 9,
                latitude: 30.5728, // 杭州市
                longitude: 120.4809,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 10,
                latitude: 28.6139, // 成都市
                longitude: 104.0668,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 11,
                latitude: 22.5431, // 深圳市
                longitude: 114.0579,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 12,
                latitude: 43.8256, // 乌鲁木齐市
                longitude: 87.6168,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 13,
                latitude: 41.7921, // 长春市
                longitude: 125.3245,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 14,
                latitude: 37.8706, // 太原市
                longitude: 112.5489,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 15,
                latitude: 31.8206, // 合肥市
                longitude: 117.2272,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 16,
                latitude: 26.5982, // 南昌市
                longitude: 115.9130,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 17,
                latitude: 27.1038, // 福州市
                longitude: 119.2965,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 18,
                latitude: 34.7466, // 郑州市
                longitude: 113.6254,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 19,
                latitude: 22.8176, // 南宁市
                longitude: 108.3669,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 20,
                latitude: 41.8303, // 西宁市
                longitude: 115.9915,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 21,
                latitude: 24.3378, // 珠海市
                longitude: 113.5755,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 22,
                latitude: 23.0796, // 惠州市
                longitude: 114.4136,
                width: 30,
                height: 30
            },
            {
                iconPath: "/images/非遗文化-01.png",
                id: 23,
                latitude: 29.6456, // 拉萨市
                longitude: 91.1175,
                width: 30,
                height: 30
            }
        ]     

    },
    

    selectTap(e) {
            const markerId = e.markerId; // 获取点击的标记 ID
            const selectedMarker = this.data.markers.find(marker => marker.id === markerId);
            console.log("id的值为"+ markerId)

            if (selectedMarker) {
                // this.setData({
                //     selectedid:markerId
                // })
                wx.navigateTo({
                  url: '/pages/heritage/heritage?id='+markerId 
                })
            }
    },
    onLoad: function () {
        // 实例化API核心类
        qqmapsdk = new QQMapWX({
            key: 'zshadeMap U3MBZ-LZIWV-OD2P4-5N5OJ-B6WX2-KIBFT'
        });
    },
    onShow: function () {
        // 调用接口
        qqmapsdk.search({
            keyword: '酒店',
            success: function (res) {
                console.log(res);
            },
            fail: function (res) {
                console.log(res);
            },
        complete: function (res) {
            console.log(res);
        }
     });
  }
})